const express = require('express')
const commentController = require('../controller/tiktok/comment')
const constant = require("../utils/constant");
const multer = require("multer");
const utils = require("../utils");

const router = express.Router()

const chunks_path = './' + constant.CHUNKS_PATH

// 配置multer
const uploadStorage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, chunks_path)  //  上传文件保存的路径
    },
    filename: function (req, file, cb) {
        let filename = `tik-tok-comment ${utils.parseTime(Date.now(), '{y}-{m}-{d} {h}-{i}-{s}')}`
        file.name = filename
        cb(null, filename + '.svg') //  上传文件的名称
    }
})
const uploadServer = multer({ storage: uploadStorage }) //  上传文件的中间件


router.post('/comment/shot-screen', uploadServer.single('file'), commentController.shotScreen)

module.exports = router
